from pywinauto import Application

# app = Application(backend='uia').start("notepad.exe")
# print(app.process)
#
# app2 = Application(backend='uia').start("F:\\sublime\\Sublime Text\\sublime_text.exe")
# print(app2.process)

app=Application(backend='uia').connect(process=35808)
print(app.process)

app2=Application(backend='uia').connect(handle=596782)
print(app2.process)